package com.tuo51.core.domain.pay;

import com.tuo51.core.domain.org.Organization;
import com.tuo51.foudation.model.Domain;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;

@Data
//comment = "机构钱包"
@Table(name = "org_wallet")
@Entity(name="org_wallet")
@EntityListeners(AuditingEntityListener.class)
public class OrgWallet extends Domain {

    @Column(columnDefinition = "VARCHAR(32) COMMENT '机构id'", unique = true)
    private String orgId;

    @Column(columnDefinition = "INT DEFAULT 0 COMMENT '钱包总充值金额'")
    private Long fullAmount = 0l;

    @Column(columnDefinition = "INT DEFAULT 0 COMMENT '已支付给金额'")
    private Long loanedAmount = 0l;

    public static OrgWallet of(Organization info){
        OrgWallet ret = new OrgWallet();

        ret.setCreated(info.getCreated());
        ret.setOrgId(info.getId());

        return ret;
    }

}
